package com.gateway.springboot.starter.router.resilience4j;

import com.gateway.router.base.handler.RouteFilterDataHandler;
import com.gateway.router.resilience4j.factory.Resilience4JRegistryFactory;
import com.gateway.router.resilience4j.handler.Resilience4JRouterFilterHandler;
import org.springframework.cloud.circuitbreaker.resilience4j.ReactiveResilience4JCircuitBreakerFactory;
import org.springframework.cloud.client.circuitbreaker.Customizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @program: api-gateway
 * @description:
 * @author: YuKai Fan
 * @create: 2025/2/25 09:37
 **/
@Configuration
public class Resilience4jRouterConfiguration {

    @Bean
    public Customizer<ReactiveResilience4JCircuitBreakerFactory> resilience4jCustomizer() {
        return Resilience4JRegistryFactory::newInstance;
    }

    @Bean
    public RouteFilterDataHandler resilience4JRouterFilterHandler() {
        return new Resilience4JRouterFilterHandler();
    }
}
